p <- ggplot(
  gapminder,
  aes(x = gdpPercap, y=lifeExp, size = pop, colour = country)
  ) +
  geom_point(show.legend = FALSE, alpha = 0.7) +
  scale_color_viridis_d() +
  scale_size(range = c(2, 12)) +
  scale_x_log10() +
  labs(x = "GDP per capita", y = "Life expectancy")
p

p + facet_wrap(~continent) +
  transition_time(year) +
  labs(title = "Year: {frame_time}")

roll_one_die <- function(dice) { 
   dice <- c("1", "2", "3", "4", "5", "6")
   sample(x = 1:6, size = 1)
}
roll_two_dice <- function() { 
   roll_one_die() + roll_one_die() }
roll_ten_dice <- function() {
map_int(1:10, ~ roll_two_dice()) 
}
roll_thousand_dice <- function() {
  map_int(1:1000, ~ roll_two_dice())
}
roll_data <- as.tibble(roll_thousand_dice()) %>% 
  arrange(desc(value)) %>% 
  count(value)
## Warning: `as.tibble()` is deprecated, use `as_tibble()` (but mind the new semantics).
## This warning is displayed once per session.
roll_six_dice <- function() {
map_int(1:6, ~ roll_two_dice()) 
}
roll_six_thousand_dice <- function() {
  map_int(1:1000, ~ roll_six_dice())
}